package common

import (
	"crypto/sha1"
	"encoding/hex"
	"sort"
	"strings"

	"go.mongodb.org/mongo-driver/bson/primitive"
)

const (
	SERVER_NAME = "aitools"
)

func GetAppKey() string {
	return primitive.NewObjectID().Hex()
}

func GetAppSecret(appKey string) string {
	sli := []string{appKey, SERVER_NAME}
	sort.Strings(sli)
	str := strings.Join(sli, "")

	h := sha1.New()
	h.Write([]byte(str))
	return hex.EncodeToString(h.Sum(nil))
}
